package cn.ulc.socket.admin.controller;

import cn.ulc.common.constant.PubDataConstant;
import cn.ulc.common.util.Result;
import cn.ulc.socket.admin.model.dto.common.BillDetailDTO;
import cn.ulc.socket.admin.model.dto.common.BillListDTO;
import cn.ulc.socket.admin.service.common.BillServ;
import cn.ulc.socket.admin.service.pubData.PubDataServ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
*
* gen controller 2019-06-15
*/
@Validated
@RestController
@RequestMapping("/companyBills")
public class BillCtrl {

    @Autowired
    BillServ billServ;
    @Autowired
    PubDataServ pubDataServ;

    @GetMapping
    public Result findList(String month,Integer year,String type){
        BillListDTO dto = billServ.findList(month,year,type);
        return Result.success(dto);
    }
    @GetMapping("/water/billList")
    public Result findWaterBillList(String month,Integer year,String type){
        String code = pubDataServ.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_BILL,"包装饮用水");
        BillListDTO dto = billServ.findList(code,month,year,type);
        return Result.success(dto);
    }
    @GetMapping("/daily/billList")
    public Result findDailyBillList(String month,Integer year,String type){
        String code = pubDataServ.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_BILL,"日用百货");
        BillListDTO dto = billServ.findList(code,month,year,type);
        return Result.success(dto);
    }
    @GetMapping("/water/detail")
    public Result findWaterDetail(String beginDate, String endDate){
        String code = pubDataServ.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_BILL,"包装饮用水");
        BillDetailDTO dto = billServ.findBillTypeDetail(code,beginDate,endDate);
        return Result.success(dto);
    }
    @GetMapping("/daily/detail")
    public Result findDailyDetail(String beginDate, String endDate){
        String code = pubDataServ.findCodeByTypeAndName(PubDataConstant.DATA_TYPE_BILL,"日用百货");
        BillDetailDTO dto = billServ.findBillTypeDetail(code,beginDate,endDate);
        return Result.success(dto);
    }
    @GetMapping("/detail")
    public Result findDetail(String beginDate, String endDate){
        BillDetailDTO dto = billServ.findDetail(beginDate,endDate);
        return Result.success(dto);
    }

}
